﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace ExamText
{
    public class DbHelper
    {
        private static readonly string constr = "server=.;uid=sa;pwd=123456;database=CMS";

        public static DataTable GetDataTable(string sql)
        {
            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, constr);
            DataTable table = new DataTable();
            dataAdapter.Fill(table);
            return table;
        }

        public static int UpdateData(string sql)
        {
            SqlConnection connection = new SqlConnection(constr);
            SqlCommand command = new SqlCommand(sql, connection);
            connection.Open();
            int res = command.ExecuteNonQuery();
            connection.Close();
            return res;
        }
    }
}